/*    */ package com.eptok.yspay.opensdkjava.util;
/*    */ 
/*    */ import sun.misc.BASE64Encoder;
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ public class SrcDesUtil
/*    */ {
/*    */   public static String encryptExtraData(String src, String extraData) throws Exception {
/* 15 */     src = String.format("%8.8s", new Object[] { src });
/*    */     
/* 17 */     String out = "";
/* 18 */     if (!StringUtil.isEmpty(extraData)) {
/* 19 */       JDES jd = new JDES();
/* 20 */       jd.SetKey(src.getBytes());
/*    */       try {
/* 22 */         out = new String((new BASE64Encoder()).encode(jd.doECBEncrypt(extraData
/* 23 */                 .getBytes("GBK"), (extraData
/* 24 */                 .getBytes("GBK")).length)));
/* 25 */       } catch (Exception e) {
/* 26 */         throw e;
/*    */       } 
/*    */     } else {
/* 29 */       out = extraData;
/*    */     } 
/* 31 */     return out;
/*    */   }
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */   
/*    */   public static String decryptExtraData(String src, String encryptExtraData) throws Exception {
/* 39 */     src = String.format("%8.8s", new Object[] { src });
/* 40 */     String out = "";
/* 41 */     if (!StringUtil.isEmpty(encryptExtraData)) {
/* 42 */       JDES jd = new JDES();
/* 43 */       jd.SetKey(src.getBytes());
/*    */       try {
/* 45 */         byte[] encryptByte = Base64Utils.decode(encryptExtraData);
/* 46 */         out = new String(jd.doECBDecrypt(encryptByte, encryptByte.length), "GBK");
/*    */       }
/* 48 */       catch (Exception e) {
/* 49 */         throw new RuntimeException("解密错误" + e.getMessage());
/*    */       } 
/*    */     } else {
/* 52 */       out = encryptExtraData;
/*    */     } 
/* 54 */     return out;
/*    */   }
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */   
/*    */   public static String encryptData(String key, String data) throws Exception {
/* 62 */     key = String.format("%8.8s", new Object[] { key });
/* 63 */     String out = "";
/* 64 */     if (!StringUtil.isEmpty(data)) {
/* 65 */       JDES jd = new JDES();
/* 66 */       jd.SetKey(key.getBytes());
/*    */       try {
/* 68 */         out = new String((new BASE64Encoder()).encode(jd.doECBEncrypt(data
/* 69 */                 .getBytes("GBK"), (data.getBytes("GBK")).length)));
/* 70 */       } catch (Exception e) {
/* 71 */         throw e;
/*    */       } 
/*    */     } else {
/* 74 */       out = data;
/*    */     } 
/* 76 */     return out;
/*    */   }
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */   
/*    */   public static String decryptData(String key, String data) throws Exception {
/* 84 */     key = String.format("%8.8s", new Object[] { key });
/* 85 */     String out = "";
/* 86 */     if (!StringUtil.isEmpty(data)) {
/* 87 */       JDES jd = new JDES();
/* 88 */       jd.SetKey(key.getBytes());
/*    */       try {
/* 90 */         byte[] encryptByte = Base64Utils.decode(data);
/* 91 */         out = new String(jd.doECBDecrypt(encryptByte, encryptByte.length), "GBK");
/*    */       }
/* 93 */       catch (Exception e) {
/* 94 */         throw e;
/*    */       } 
/*    */     } else {
/* 97 */       out = data;
/*    */     } 
/* 99 */     return out;
/*    */   }
/*    */ }


/* Location:              D:\repository\io\github\ysgatesdk\yspay-opensdk-java\1.0.1\yspay-opensdk-java-1.0.1.jar!\com\eptok\yspay\opensdkjav\\util\SrcDesUtil.class
 * Java compiler version: 8 (52.0)
 * JD-Core Version:       1.1.3
 */